<template>
  <div class="detail-data-show">
    <el-divider>数据说明</el-divider>
    <w-simplemde ref="WSimplemde" :is-edit="isSuperAdmin" @save="saveClick"></w-simplemde>
  </div>
</template>

<script lang="ts">
  import { Vue, Component } from 'vue-property-decorator'
  import { SimplemdeType } from '@/components/global/simplemde/types'
  import { Getter } from 'vuex-class'
  import WSimplemde from "@/components/global/simplemde/index.vue";
  import EnumModel from "@/models/EnumModel";
  import YBPopView from "@/utils/popView";

  @Component({
    components: {
      WSimplemde
    }
  })
  export default class DataShow extends Vue {

    @Getter('isSuperAdmin') isSuperAdmin!: boolean
    model!: EnumModel

    show(model: EnumModel) {
      this.model = model;
      (this.$refs.WSimplemde as SimplemdeType).setData(model.dataShow)
    }

    saveClick() {
      this.model.dataShow = (this.$refs.WSimplemde as SimplemdeType).getData()
      if (!this.model.dataShow) {
        YBPopView.msgError('请设置数据')
        return
      }
      this.model.updataDataShow().then(() => {
        YBPopView.msgSuccess('保存成功')
      })
    }
  }

</script>

<style lang="scss">

</style>
<style scoped lang="scss">

</style>
